import returnVuePath from '../utils/returnVuePath.js'
import fs from 'node:fs'
const FindModule = ({ app, root }) => {
    app.use(async (ctx, next) => {
        let vueModulePath = returnVuePath(root)
        //如果前缀是/moule/
        if (ctx.path.startsWith('/modules/')) {
            let id = ctx.path.replace('/modules/', '')
            ctx.body = fs.readFileSync(vueModulePath[id], 'utf-8')
            ctx.type = 'js'
        }else{
            await next()
        }
       
    })

}
export default FindModule